﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class CTKHTraHangBlo
    {
        #region "Khai báo các biến"
        private CTKHTraHangDAO da;
        private CTKHTraHangDTO _CTKHTH;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTKHTraHangDTO CTKHTH
        {
            get { return _CTKHTH; }
            set { _CTKHTH = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public CTKHTraHangBlo()
        {            
            da = new CTKHTraHangDAO();
        }
        public bool InsertCTKHTraHang(string MaMH, string MaKHTh, int SoLuong, double DonGia, float ChietKhau, double ThanhTien)
        {
            _CTKHTH = new CTKHTraHangDTO(MaMH, MaKHTh, SoLuong, DonGia, ChietKhau, ThanhTien);
            if (!da.InsertCTKHTraHang(CTKHTH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTKHTraHang(string MaMH, string MaKHTh, int SoLuong, double DonGia, float ChietKhau, double ThanhTien)
        {
            _CTKHTH = new CTKHTraHangDTO(MaMH, MaKHTh, SoLuong, DonGia, ChietKhau, ThanhTien);
            if (!da.UpdateCTKHTraHang(CTKHTH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTKHTraHang(string MaMH,string MaKHTH)
        {
            if (!da.DeleteCTKHTraHang(MaMH,MaKHTH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTKHTraHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTKHTraHang();
            return ds;
        }
        #endregion 
    }
}